/*************************************************************************

Framework\System.Byte.cpp

	-by Miles Chen (stainboyx@hotmail.com) 2009-02-07

*************************************************************************/

#pragma once

#include "commdef-int.h"

N System{N NByte{

	int CopyTo(LPSTR lpszDest, LPCSTR lpszSrc, int nSize)
	{
		int i = 0;

		while(i++<nSize)
		{
			*lpszDest++ = *lpszSrc++;
		}

		return nSize;
	}

//int Compare(LPCSTR lpszStr1, LPCSTR lpszStr2, int nSize)
//{
//    int ret = 0 ;
//	int i = 0;
//
//    while( ! (ret = (int)(*lpszStr1 - *lpszStr2)) && i++<nSize)
//            ++lpszStr1, ++lpszStr2;
//
//    if ( ret < 0 )
//            ret = -1 ;
//    else if ( ret > 0 )
//            ret = 1 ;
//
//    return( ret );
//}


/***
*Byte::Compare - compare two strings, returning less than, equal to, or greater than
*
*Purpose:
*       STRCMP compares two strings and returns an integer
*       to indicate whether the first is less than the second, the two are
*       equal, or whether the first is greater than the second.
*
*       Comparison is done byte by byte on an UNSIGNED basis, which is to
*       say that Null (0) is less than any other character (1-255).
*
*Entry:
*       const char * src - string for left-hand side of comparison
*       const char * dst - string for right-hand side of comparison
*
*Exit:
*       returns -1 if src <  dst
*       returns  0 if src == dst
*       returns +1 if src >  dst
*
*Exceptions:
*
*******************************************************************************/

int Compare (
        const char * src,
        const char * dst,
		int nSize
        )
{
		//int ret = 0 ;
		//int i = 0;
		//
		//while( ! (ret = *(unsigned char *)src - *(unsigned char *)dst) && i < nSize)
		//        ++src, ++dst, ++i;
		//
		//if ( ret < 0 )
		//        ret = -1 ;
		//else if ( ret > 0 )
		//        ret = 1 ;
		//
		//return( ret );
	for(int i=0; i<nSize; i++)
	{
		if(*src++ != *dst++) return 1;
	}
	return 0;
}


}}